package com.dylovedz.javafxphone.service;

import com.dylovedz.javafxphone.domain.LastOpenFile;
import com.dylovedz.javafxphone.repository.LastOpenFileRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LastOpenFileService {

    @Resource
    private LastOpenFileRepository lastOpenFileRepository;

    public LastOpenFile findById(Integer id) {
        return lastOpenFileRepository.findById(id).orElse(new LastOpenFile());
    }

    public void saveOrUpdateById(Integer id, String lastPath) {
        LastOpenFile lastFile = new LastOpenFile();
        lastFile.setId(id);
        lastFile.setLastPath(lastPath);
        lastOpenFileRepository.save(lastFile);
    }
}
